

class selectMark {
    constructor(parent) {
        this.parent = parent;
        this.palette = new PIXI.Graphics();
        this.palette.alpha = '0.2';
        parent.ContentGrounp.addChild(this.palette);
        this.parent.zIndex = 9999;
        this.cache = [];
    }
    setStartPoint(x, y) {
        this.cache = [x / this.parent.scale, y / this.parent.scale];
        this.palette.position.set(x / this.parent.scale, y / this.parent.scale);
    }
    setMovePoint(x, y) {
        this.palette.clear();
        this.palette.beginFill(0x66CCFF);
        this.palette.lineStyle(1, 0x1C6EAA, 1).drawRect(0, 0, (x / this.parent.scale - this.cache[0]), (y / this.parent.scale - this.cache[1]));
    }
    clear() { 
        this.palette.clear();
        this.cache = [];
    }
    getValue(x, y) {
        this.palette.clear();
        const _cache = [Math.min(this.cache[0], x / this.parent.scale), Math.min(this.cache[1], y / this.parent.scale), Math.max(this.cache[0], x / this.parent.scale), Math.max(this.cache[1], y / this.parent.scale)];
        this.cache = [];
        return {
            x: _cache[0],
            y: _cache[1],
            width: _cache[2] - _cache[0],
            height: _cache[3] - _cache[1],
        };
    }
}


export default selectMark